import Snake from './Snake';
export default class Food {
    constructor() {
        this.snake = new Snake();
        this.element = document.querySelector("#food");
    }
    get X() {
        return this.element.offsetLeft;
    }
    ;
    get Y() {
        return this.element.offsetTop;
    }
    ;
    change() {
        let top = Math.round(Math.random() * 29) * 10;
        let left = Math.round(Math.random() * 29) * 10;
        for (let i = 0; i < this.snake.bodies.length; i++) {
            if (this.snake.bodies[i].offsetTop === top && this.snake.bodies[i].offsetLeft === left) {
                top = Math.round(Math.random() * 29) * 10;
                left = Math.round(Math.random() * 29) * 10;
                i = -1;
            }
        }
        this.element.style.left = left + "px";
        this.element.style.top = top + "px";
    }
}
;
